<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../../inc/conn.asp"-->
<%
edit=checkstr(inHTML(request("edit")))
if edit<>"" then
  set rs=server.CreateObject("adodb.recordset")
  sql="select * from inquiryCart where uid='"&request.Cookies("order")&"' and id="&edit&""
  rs.open sql,conn,1,1
  if rs.eof and rs.bof then
  response.Write("<script>window.location.href='/inquiry';</script>")
  response.End
  else
    url=rs("url")
	title=rs("title")
	qty=rs("qty")
	content=rs("content")
  end if
  rs.close
  set rs=nothing
end if
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>填写询价单 </title>
<meta name="keywords" content="填写询价单" />
<meta name="description" content="填写询价单" />
<link href="favicon.ico" rel="shortcut icon" type="image/x-icon"/>
<link rel="stylesheet" type="text/css" href="/css/style.css" />
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){ 
	$('#select_1').change(function(){ 
		$('#search_1').val($(this).find("option:selected").text());
	});
}); 
$(function (){
  $(".main_class_li").hover(function(){
	$(".child_class",this).show();
  });
  $(".main_class_li").mouseleave(function(){
	$(".child_class",this).hide();
  });
});
</script>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var checkflag = "false";
function checkall(field) {
if (checkflag == "false") {
for (i = 0; i < field.length; i++) {
field[i].checked = true;}
checkflag = "true";}
else {
for (i = 0; i < field.length; i++) {
field[i].checked = false; }
checkflag = "false";	}
}
//end-->
</script>
</head>
<body>

<!--#include file="../common/topshopping.asp"-->


<div class="fullwidth bg2">
	<div class="place ">
		<a href="/">首页</a> &gt; <a href="/shopping">我要代购</a> &gt; 填写询价单
	</div>
</div>

<!--main-->
<div class="fullwidth bg1">
	<div class="main">
		<div class="clear20"></div>
		<img src="/images/dg_step.jpg" />
		<div class="clear20"></div>
		<div class="dg_box_6">
			<div class="dg_title_2"><h2>加入询价商品</h2></div>
			<p class="dg_tip_1">※产品链接或产品图片或名称必须填一项</p>
			<form action="/inquiry/save" method="post" enctype="multipart/form-data" class="registerform dg_form_1">
				<dl>
					<dd>
						<span class="span_l">商品链接：</span>
						<input type="text" name="url" value="<%=url%>" class="text" datatype="url" ignore="ignore" nullmsg="请输入商品链接！" errormsg="商品链接输入错误" />
						<!--<a href="" class="dg_a_1 pmt2">一键读取商品信息</a>--><span class="Validform_checktip"></span>
					</dd>
					<dd>
						<span class="span_l">商品名：</span>
						<input type="text" name="title" value="<%=title%>" class="text" datatype="*1-100" ignore="ignore" nullmsg="请输入商品名称！" errormsg="商品名称输入错误"  />
                        <span class="Validform_checktip"></span>
					</dd>
					<dd>
						<span class="span_l">图片：</span>
						<input type="file" name="pic" class="text text_1" datatype="/(JPG|GIF|PNG|jpg|gif|png)/" ignore="ignore" nullmsg="请选择图片！" errormsg="图片格式错误" />
						<span class="Validform_checktip"></span>
					</dd>
					<dd>
						<span class="span_l">数量：</span>
						<input type="text" name="qty" value="<%=qty%>" class="text text_1" datatype="n" nullmsg="请填写购买数量！" errormsg="数量输入错误" />
                        <span class="Validform_checktip"></span>
					</dd>
					<dd>
						<span class="span_l">备注：</span>
						<textarea class="ta_1" name="content" datatype="*1-500" ignore="ignore" nullmsg="请输入商品购买备注！" errormsg="备注字符1,500"><%=content%></textarea>
                        <span class="Validform_checktip"></span>
					</dd>
					<dd>
						<span class="span_l"></span>
						<input type="submit" class="btn_21" value="<%if edit<>"" then response.Write "保存" else response.Write "加入询价单"%>" />
                        <input type="hidden" name="t" value="y" />
                        <input type="hidden" name="id" value="<%=edit%>" />
					</dd>
				</dl>
			</form>
		</div>
		<div class="clear20"></div>
		<div class="dg_box_6">
			<div class="dg_title_2"><h2>询价中商品</h2></div>
			<form class="registerform" action="" method="post">
            <table class="stable stable_1 stable_2 stable_3">
				<tr>
					<th width="50"><input type="checkbox" name="checkbox2" onClick="javascript:checkall(this.form);" /> 全选</th>
					<th>图片</th>
					<th>备注</th>
					<th>购买数量</th>				
					<th>操作</th>				
				</tr>
                
                
                <%		
				set rsnewx=server.CreateObject("adodb.recordset")
				sql="select * from InquiryCart where uid='"&request.Cookies("order")&"' order by id"
				rsnewx.open sql,conn,1,3
				if not rsnewx.eof then
				do while not rsnewx.eof 
				%>
				<tr>
					<td><input type="checkbox" name="checkbox" value="<%=rsnewx("id")%>" onClick="javascript:checkall(this.form);" /></td>
					<td style="word-wrap:break-word; width:80px; line-height:18px; padding-bottom:8px; padding-top:8px">
                    
                    <%
					if rsnewx("pic")<>"" then response.Write "<img src='"&rsnewx("pic")&"' width='80' height='80' alt='' class='mtb10'>"
					if rsnewx("title")<>"" then response.Write "<br>"&rsnewx("title")
					if rsnewx("url")<>"" then response.Write "<br>"&rsnewx("url")
					%>
                    
                    
                    </td>
					<td style="word-wrap:break-word; width:300px; line-height:18px; padding-bottom:8px; padding-top:8px; padding-left:30px"><%=rsnewx("content")%></td>
					<td><%=rsnewx("qty")%></td>
					<td><a href="?del=<%=rsnewx("id")%>" class="gray_u">删除</a>&nbsp;&nbsp;&nbsp;<a href="?edit=<%=rsnewx("id")%>" class="gray_u">修改</a></td>
				</tr>
                <%
				rsnewx.movenext
				loop
				rsnewx.close
				set rsnewx=nothing
				end if		 
				%>
                
                
				
				
			</table>
			<div class="btn">
				<a href="javascript:void(0);" class="btn_sub btn_21 btn_22">提交</a>
                <input type="hidden" name="t" value="y" />
			</div>
            </form>
		</div>
	</div>
</div>

<div class="clear"></div>



<!--#include file="../common/footerauctions.asp"-->



<link rel="stylesheet" href="/Validform/css/style.css" type="text/css" media="all" />
<script type="text/javascript" src="/Validform/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="/Validform/js/Validform_v5.3.2_min.js"></script>
<script type="text/javascript">
$(function(){
	//$(".registerform").Validform();  //就这一行代码！;
		
	$(".registerform").Validform({
		btnSubmit:".btn_sub", 
		//btnReset:".btn_reset",
		//tiptype:1, 
		showAllError:true,
		tiptype:function(msg,o,cssctl){
			//msg：提示信息;
			//o:{obj:*,type:*,curform:*}, obj指向的是当前验证的表单元素（或表单对象），type指示提示的状态，值为1、2、3、4， 1：正在检测/提交数据，2：通过验证，3：验证失败，4：提示ignore状态, curform为当前form对象;
			//cssctl:内置的提示信息样式控制函数，该函数需传入两个参数：显示提示信息的对象 和 当前提示的状态（既形参o中的type）;
			if(!o.obj.is("form")){//验证表单元素时o.obj为该表单元素，全部验证通过提交表单时o.obj为该表单对象;
				var objtip=o.obj.siblings(".Validform_checktip");
				cssctl(objtip,o.type);
				objtip.text(msg);	
			}
		}
	});
})
</script>
</body>
</html>
<%
'添加
if request.Form("t")="y" then
  
  checkbox=request.Form("checkbox")
  uid=checkstr(inHTML(request.cookies("u")("uid")))
  
  if uid="" then
  session("returnurl")="/inquiry"
  response.Redirect "/login"
  response.end
  end if  
  
  if checkbox="" then
  response.write"<script>alert('请选择商品');</script>"
  response.write"<script>window.history.back(-1);</script>"
  response.end
  end if

  set rslistx=server.CreateObject("adodb.recordset")
  sql="select * from inquiryCart where uid='"&request.Cookies("order")&"' and id in("&checkbox&")"
  rslistx.open sql,conn,1,3
  if not rslistx.eof then
  do while not rslistx.eof
  '产品写入
		Set rsdetail=server.createobject("adodb.recordset")
		rsdetail.Open "select * from inquiry" ,conn,2,3
		rsdetail.AddNew 
		rsdetail("uid")=uid  '会员ID
		rsdetail("url")=rslistx("url") 
		rsdetail("title")=rslistx("title") 
		rsdetail("pic")=rslistx("pic") 
		rsdetail("qty")=rslistx("qty") 
		rsdetail("content")=rslistx("content") 
		rsdetail.Update
		rsdetail.close
		set rsdetail=nothing
  rslistx.movenext
  loop
  rslistx.close
  set rslistx=nothing
  end if
  
  conn.execute("delete from inquiryCart where uid='"&request.Cookies("order")&"' and id in("&checkbox&")")
  response.Redirect "/user/order/inquiry"
end if


'删除
if request.QueryString("del")<>"" then
conn.execute("delete from inquiryCart where uid='"&request.Cookies("order")&"' and id="&request.QueryString("del")&"")
response.Redirect "/inquiry"
end if
%>